#region " using "
using System;
using System.Data;
using System.Web.UI.WebControls;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Threading;
using System.Globalization;
using System.Text;
using System.IO;
using Smarty;
#endregion

public partial class Ccategory_View : AspNetRunnerPage
{
    string filename="";	
    string message="";
    string all = string.Empty;
    string pdf = string.Empty;
    int mypage = 1;
    int id = 1;
    IDictionary<string, object> key = new Dictionary<string, object>();
    string templatefile = string.Empty;

    Data.categoryController controller = new Data.categoryController();
    Data.category item = null;

    protected void Page_Init( object sender,  System.EventArgs e)  
    {
        strTableName = "category";
        strTableNameLocale = "category";
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        all = (string)Request["all"];
        pdf = (string)Request["pdf"];

	        key.Add("CateID", Request["editid1"]);

                CheckSecurity();
        BuildForm();
        BuildBody();
        BuildPdfControl();
        output.Append(func.BuildOutput(this, @"~\admin\category_view.aspx", smarty));
        this.Response.Write(output.ToString());
        this.Response.End();
    }

        private bool CheckSecurity()
    {
        if(string.IsNullOrEmpty(UserName))
        { 
            MyUrl = this.Request.AppRelativeCurrentExecutionFilePath;
            this.Server.Transfer("~/admin/login.aspx?message=expired");
	        return false;
        }
                if(!BaseCheckSecurity(OwnerID, "Search") && !BaseCheckSecurity(OwnerID, "View"))
        {
                }
        return true;
    }

    private void BuildForm()
    {
        if(key.Count > 1)
        {
            item = controller.FetchByManyID(key);
        }
        else
        {
            item = Data.category.FetchByID(Request["editid1"]);
        }
	                        Control control_key_CateID = new Control("CateID", item.CateID, false, smarty, this.Request, builder, MODE.MODE_VIEW);
                smarty.Add("show_key1", Control.HTMLEncodeSpecialChars(control_key_CateID.GetData()));
        if(item != null)
        {

            string value="";
            string keylink = string.Empty;
	        keylink +="&key1=" + Control.HTMLEncodeSpecialChars(this.Server.UrlEncode(item.CateID.ToString()));

        //	CateID - 
                Control control_CateID = new Control("CateID", item.CateID, false, smarty, this.Request, builder, MODE.MODE_VIEW);
	                                value = control_CateID.GetData();
			        value = control_CateID.ProcessLargeText(value,"field=CateID" + keylink,"",MODE.MODE_VIEW);
            smarty.Add("CateID_value",value);
	        smarty.Add("CateID_fieldblock",true);

        //	CateName - 
                Control control_CateName = new Control("CateName", item.CateName, false, smarty, this.Request, builder, MODE.MODE_VIEW);
	                                value = control_CateName.GetData();
			        value = control_CateName.ProcessLargeText(value,"field=CateName" + keylink,"",MODE.MODE_VIEW);
            smarty.Add("CateName_value",value);
	        smarty.Add("CateName_fieldblock",true);

        //	CateParent - 
                Control control_CateParent = new Control("CateParent", item.CateParent, false, smarty, this.Request, builder, MODE.MODE_VIEW);
	                                control_CateParent.Value = func.GetLookupValue(control_CateParent.FieldInfo);
			        value=control_CateParent.DisplayLookupWizard();
                  
            smarty.Add("CateParent_value",value);
	        smarty.Add("CateParent_fieldblock",true);

        //	Description - 
                Control control_Description = new Control("Description", item.Description, false, smarty, this.Request, builder, MODE.MODE_VIEW);
	                                value = control_Description.GetData();
			        value = control_Description.ProcessLargeText(value,"field=Description" + keylink,"",MODE.MODE_VIEW);
            smarty.Add("Description_value",value);
	        smarty.Add("Description_fieldblock",true);

        //	VipLevel - 
                Control control_VipLevel = new Control("VipLevel", item.VipLevel, false, smarty, this.Request, builder, MODE.MODE_VIEW);
	                                value = control_VipLevel.GetData();
			        value = control_VipLevel.ProcessLargeText(value,"field=VipLevel" + keylink,"",MODE.MODE_VIEW);
            smarty.Add("VipLevel_value",value);
	        smarty.Add("VipLevel_fieldblock",true);

        //	Active - Checkbox
                Control control_Active = new Control("Active", item.Active, false, smarty, this.Request, builder, MODE.MODE_VIEW);
	            			        value = control_Active.GetData();
            smarty.Add("Active_value",value);
	        smarty.Add("Active_fieldblock",true);

        //	Price - Number
                Control control_Price = new Control("Price", item.Price, false, smarty, this.Request, builder, MODE.MODE_VIEW);
	                                value = control_Price.GetData();
			        value = control_Price.ProcessLargeText(value,"field=Price" + keylink,"",MODE.MODE_VIEW);
            smarty.Add("Price_value",value);
	        smarty.Add("Price_fieldblock",true);

        //	Image - 
                Control control_Image = new Control("Image", item.Image, false, smarty, this.Request, builder, MODE.MODE_VIEW);
	                                value = control_Image.GetData();
			        value = control_Image.ProcessLargeText(value,"field=Image" + keylink,"",MODE.MODE_VIEW);
            smarty.Add("Image_value",value);
	        smarty.Add("Image_fieldblock",true);

        //	Status - 
                Control control_Status = new Control("Status", item.Status, false, smarty, this.Request, builder, MODE.MODE_VIEW);
	                                value = control_Status.GetData();
			        value = control_Status.ProcessLargeText(value,"field=Status" + keylink,"",MODE.MODE_VIEW);
            smarty.Add("Status_value",value);
	        smarty.Add("Status_fieldblock",true);

        //	CreatedDate - Short Date
                Control control_CreatedDate = new Control("CreatedDate", item.CreatedDate, false, smarty, this.Request, builder, MODE.MODE_VIEW);
	                                value = control_CreatedDate.GetData();
			        value = control_CreatedDate.ProcessLargeText(value,"field=CreatedDate" + keylink,"",MODE.MODE_VIEW);
            smarty.Add("CreatedDate_value",value);
	        smarty.Add("CreatedDate_fieldblock",true);

        //	UpdatedDate - Short Date
                Control control_UpdatedDate = new Control("UpdatedDate", item.UpdatedDate, false, smarty, this.Request, builder, MODE.MODE_VIEW);
	                                value = control_UpdatedDate.GetData();
			        value = control_UpdatedDate.ProcessLargeText(value,"field=UpdatedDate" + keylink,"",MODE.MODE_VIEW);
            smarty.Add("UpdatedDate_value",value);
	        smarty.Add("UpdatedDate_fieldblock",true);
        }
    }

    private void BuildBody()
    {
        IDictionary<string, string> body = new Dictionary<string, string>();
        body["begin"]="";
                
        smarty.Add("body",body);
        smarty.Add("style_block",true);
        smarty.Add("stylefiles_block",true);
    }

    protected void BuildPdfControl()
    {
        if(string.IsNullOrEmpty(pdf) && string.IsNullOrEmpty(all))
        {
	        smarty.Add("back_button",true);
	        smarty.Add("backbutton_attrs","onclick=\"window.location.href='category_list.aspx?a=return'\"");
        }

        string oldtemplatefile = templatefile;
        templatefile = @"~\admin\category_view.aspx";
    }
}
